import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '@/views/Home.vue'



Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },{
    path:'/login',
    name:'login',
    component: () => import('@/views/Login.vue')
  },{
    path:'/register',
    name:'register',
    component:()=>import('@/views/Register.vue')
  },{
    path:'/goodsDetail',
    name:'goodsDetail',
    component:()=>import('@/views/GoodsDetail.vue')
  },{
    path:'/cateGoods',
    name:'cateGoods',
    component:()=>import('@/views/CateGoods.vue')
  },{
    path:'/searchGoods',
    name:'searchGoods',
    component:()=>import('@/views/SearchGoods.vue')
  },{
    path:'/cart',
    name:'cart',
    component:()=>import('@/views/Cart.vue')
  },{
    path:'/pay',
    name:'pay',
    component:()=>import('@/views/Pay.vue')
  },{
    path:'/order',
    name:'order',
    component:()=>import('@/views/Order.vue')
  }
]

/** 解决跳转重复路由报错问题 */ 


const router = new VueRouter({
  routes
})

// const routerPush = router.push;
// router.push = path => {
//   // 判断下当前路由是否就是要跳转的路由
//   if (router.currentRoute.fullPath.includes(path)) return;
//   return routerPush.call(router, path);
// }

export default router
